//
//  TKIMAudioHelper.h
//  TKIM
//
//  Created by liupm on 15/10/26.
//  Copyright © 2015年 liupm. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKIT/UIKit.h>

typedef NS_ENUM(NSInteger,TKIMAudioPlayMode)
{
    TKIMAudioPlayModePlayback,//外放
    TKIMAudioPlayModeEarpiece//听筒
};

@protocol TKIMAudioDelegate;

@interface TKIMAudioHelper : NSObject

@property(nonatomic,strong) NSString *recordFileUrl;
@property(nonatomic,weak) id<TKIMAudioDelegate> delegate;

/**
 *  开始录制
 */
- (void)record;


/**
 *  暂定录制
 */
- (void)pauseRecord;

/**
 *  恢复录制
 *  恢复录音只需要再次调用record，AVAudioSession会帮助你记录上次录音位置并追加录音
 *
 *  @param sender 恢复按钮
 */
- (void)resumeRecord;


/**
 *  停止录制
 */
- (void)stopRecord;

/**
 *  @Author lpm, 15-10-26 13:10:55
 *
 *  @brief  取消录制
 *
 *  @return
 */
-(BOOL)cancel;


/**
 *  播放音频
 */
-(void)play:(NSURL *)url;


/**
 *  播放音频
 */
-(void)play:(NSURL *)url mode:(TKIMAudioPlayMode)mode;


/**
 *  @Author lpm, 16-06-02 17:06:43
 *
 *  @brief  切换播放模式
 *
 *  @param mode
 */
-(BOOL)changePlayMode:(TKIMAudioPlayMode)mode;


/**
 *  暂停播放
 */
-(void)pausePlay;


/**
 *  停止播放
 */
-(void)stopPlay;


/**
 *  @Author lpm, 15-12-18 11:12:40
 *
 *  @brief  新增api,获取录音权限. 返回值,YES为无拒绝,NO为拒绝录音
 *
 *  @return
 */
- (BOOL)canRecord;

@end

@protocol TKIMAudioDelegate <NSObject>

/**
 *  @Author lpm, 15-10-26 14:10:34
 *
 *  @brief  录制结束
 *
 *  @param recorderUrl   录制文件地址
 *  @param audioDuration 录制时长
 *  @param flag          是否成功
 */
-(void)audioRecorderDidFinishRecording:(NSString *)recorderUrl fileName:(NSString *)fileName  audioDuration:(float)audioDuration successfully:(BOOL)flag;


/**
 *  @Author lpm, 15-10-26 15:10:38
 *
 *  @brief  声音大小改变
 */
-(void)audioPowerChange:(CGFloat)progress;



/**
 *  @Author lpm, 15-10-27 09:10:14
 *
 *  @brief  播放完成
 *
 *  @param flag 是滞播放成功
 */
-(void)audioPlayerDidFinishPlaying:(BOOL)flag;


@end